-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] Use describeTreeView
for icons tests
#12672
[core] Use describeTreeView
for icons tests
#12672
Conversation
@@ -35,7 +35,11 @@ export interface RichTreeViewSlots extends DefaultTreeViewPluginSlots { | |||
export interface RichTreeViewSlotProps<R extends {}, Multiple extends boolean | undefined> | |||
extends DefaultTreeViewPluginSlotProps { | |||
root?: SlotComponentProps<'ul', {}, RichTreeViewProps<R, Multiple>>; | |||
item?: SlotComponentProps<typeof TreeItem, {}, RichTreeViewItemSlotOwnerState>; | |||
item?: SlotComponentPropsFromProps< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had some typing issues while writing those tests so I improved the typing of this slot.
SlotComponentPropsFromProps
allows us to skip the typeof TreeItem
which can be expensive.
I also added TreeItem2Props
which was completely missing
@@ -157,6 +157,10 @@ const useUtilityClasses = (ownerState: TreeItem2OwnerState) => { | |||
return composeClasses(slots, getTreeItemUtilityClass, classes); | |||
}; | |||
|
|||
type TreeItem2Component = (( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to have this one for consistency
@@ -14,15 +14,15 @@ import { | |||
DescribeTreeViewItem, | |||
} from './describeTreeView.types'; | |||
|
|||
const innerDescribeTreeView = <TPlugin extends TreeViewAnyPluginSignature>( | |||
const innerDescribeTreeView = <TPlugins extends TreeViewAnyPluginSignature[]>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now pass an array of plugins. I needed it to access defaultExpandedItems
in useTreeIcons.test.tsx
describeTreeView
for icons tests
Deploy preview: https://deploy-preview-12672--material-ui-x.netlify.app/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! 🎉
Left a super small comment 👌
packages/x-tree-view/src/internals/plugins/useTreeViewIcons/useTreeViewIcons.test.tsx
Outdated
Show resolved
Hide resolved
…eTreeViewIcons.test.tsx Co-authored-by: Nora <[email protected]> Signed-off-by: Flavien DELANGLE <[email protected]>
Signed-off-by: Flavien DELANGLE <[email protected]> Co-authored-by: Nora <[email protected]>
Signed-off-by: Flavien DELANGLE <[email protected]> Co-authored-by: Nora <[email protected]>
Part of #12433
Part of #12434
The new tests are a lot more detailed but the idea remains the same